﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManagerRole.aspx.cs" Inherits="RegisterWeb.Manager.SystemUserManager.UserManagerRole" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta name="keywords" content="jquery,ui,easy,easyui,web"/>
	<meta name="description" content="easyui help you build your web page easily!"/>
	<title>jQuery EasyUI CRUD Demo</title>
	 <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />

	<style type="text/css">
		#fm{
			margin:0;
			padding:10px 30px;
		}
		.ftitle{
			font-size:14px;
			font-weight:bold;
			color:#666;
			padding:5px 0;
			margin-bottom:10px;
			border-bottom:1px solid #ccc;
		}
		.fitem{
			margin-bottom:5px;
		}
		.fitem label{
			display:inline-block;
			width:80px;
		}
	</style>
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script type="text/javascript">
	    var url;
	    var row1;
	    function newUser() {
	        $('#dlg').dialog('open').dialog('setTitle', 'New User');
	        $('#fm').form('clear');
	        url = 'ashx/RoleService.ashx?action=add';
	    
	    }
	    function editUser() {
	        var row = $('#dg').datagrid('getSelected');
	        if (row) {
	            $('#dlg').dialog('open').dialog('setTitle', 'Edit User');
	            $('#fm').form('load', row);
	            url = 'ashx/RoleService.ashx?action=updata&id=' + row.Role_ID;
	        }
	    }
	    function saveUser() {
	        $('#fm').form('submit', {
	            url: url,
	            onSubmit: function () {
	                return $(this).form('validate');
	            },
	            success: function (result) {
	              //   alert(result);
	                var result = eval('(' + result + ')');
	                if (result.success) {
	                    $.messager.show({
	                        title: 'Success',
	                        msg: result.msg
	                    });
	                    $('#dlg').dialog('close'); 	// close the dialog
	                    $('#dg').datagrid('reload'); // reload the user data
	                } else {
	                    $.messager.show({
	                        title: 'Error',
	                        msg: result.msg
	                    });
	                }
	            }
	        });
	    }
	    //编辑用户部分
	    function RoleModelManager() {
	        $("#RoleModelManager").dialog({
	            "title": "角色权限管理",
	            width:880,
	            height: 320,
	            href: 'RoleModelManager.aspx'
	        });
	        row1 = $('#dg').datagrid('getSelected');
	        var row = $('#dg').datagrid('getSelected');      
	        if (row) {
	            $('#RoleModelManager').dialog('open');
	            url = 'ashx/AdminInfoManagerService.ashx?action=edit&id=' + row.ID;
	            formId = "#rolemodel";
	            dialogId = "#RoleModelManager";   
                   $('#tt').datagrid('reload'); 
	        }
	        else {
	            $.messager.alert("提示", "您没有选中任何行！");
	        }

	    }
	    function RoleModelclose() {
	        $('#RoleModelManager').dialog('close');
	        window.location.reload();
	    }



	    function removeUser() {
	        var row = $('#dg').datagrid('getSelected');
	        if (row) {
	            $.messager.confirm('Confirm', 'Are you sure you want to remove this user?', function (r) {
	                if (r) {
	                    $.post('ashx/RoleService.ashx', { id: row.Role_ID, "action": "delete" }, function (data, status) {
	                        if (data=="success") {
	                            $('#dg').datagrid('reload'); // reload the user data
	                        } else {
	                            $.messager.show({	// show error message
	                                title: 'Error',
	                                msg: result.msg
	                            });
	                        }
	                    });
	                }
	            });
	        }
	    }
	</script>
</head>
<body>
	<table id="dg" title="角色管理" class="easyui-datagrid" style="width:850px;height:550px"
			url= "ashx/RoleService.ashx?action=get"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true"  pageSize="20">
		<thead>
			<tr>
				<th field="Role_ID" width="50">角色编号</th>
				<th field="Role_Name" width="50">角色名</th>
				<th field="Role_string" width="50">角色描述</th>
				<th field="Role_Degree" width="50">角色等级</th>
			</tr>
		</thead>
	</table>
	<div id="toolbar">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">新建角色</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">修改角色</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeUser()">删除角色</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-remove"   plain="true"  onclick="RoleModelManager()">指定权限</a>                                         
                      
	</div>
	
	<div id="dlg" class="easyui-dialog" style="width:500px;height:380px;padding:10px 20px"
			closed="true" buttons="#dlg-buttons">
		<div class="ftitle">角色信息</div>
		<form id="fm" method="post" novalidate>
			<div class="fitem">
				<label>角色名:</label>
				<input name="Role_Name" class="easyui-validatebox" required="true">
			</div>
			<div class="fitem">
				<label>角色描述:</label>
                	<textarea name="Role_Describe" style="width:200px;height:150px"></textarea>
			</div>
			<div class="fitem">
				<label>角色等级:</label>
				<input name="Role_Degree"  class="easyui-validatebox" required="true">
			</div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">Save</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
	</div>
      <div id="RoleModelManager" class="easyui-dialog" closed="true" buttons="#RoleModelManager-buttons" style="">
        	</div>
                <div id="RoleModelManager-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="RoleModelclose()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="RoleModelclose()">关闭</a>
			</div>
</body>
</html>